<?php
class TextScrollVo extends SzAbstractMySqlVo
{

    private $tid;
    private $type;
    private $time;
    private $start;
    private $end;
    private $content;

    /**
     * Initialize TextScrollVo.
     *
     * @param $tid
     * @param $type
     * @param $time
     * @param $start
     * @param $end
     * @param $content
     * @param boolean $isInsert default false, means for now this vo is initialized not for insert process
     * @return TextScrollVo
     */
    public function __construct($tid, $type, $time, $start, $end, $content, $isInsert = false) {
        $this->tid = $tid;
        $this->type = $type;
        $this->time = json_decode($time, true);
        $this->start = $start;
        $this->end = $end;
        $this->content = $content;

        $this->isInsert = $isInsert;
        $this->voClassName = 'TextScrollVo';
        $this->ormName = 'TextScroll';
    }

    /**
     * @see SzAbstractVo::toArray
     */
    public function toArray($needEncode = false)
    {
        return array(
            'tid' => $this->getTid(),
            'type' => $this->getType(),
            'time' => ($needEncode) ? $this->getTime() : $this->getRawTime(),
            'start' => $this->getStart(),
            'end' => $this->getEnd(),
            'content' => $this->getContent(),
        );
    }

    /**
     * @see SzAbstractVo::toEntireArray
     */
    public function toEntireArray($needEncode = false)
    {
        return array(
            'tid' => $this->getTid(),
            'type' => $this->getType(),
            'time' => ($needEncode) ? $this->getTime() : $this->getRawTime(),
            'start' => $this->getStart(),
            'end' => $this->getEnd(),
            'content' => $this->getContent(),
        );
    }

    /**
     * @see SzAbstractVo::toPureArray
     */
    public function toPureArray()
    {
        return array(
            $this->getTid(),
            $this->getType(),
            $this->getTime(),
            $this->getStart(),
            $this->getEnd(),
            $this->getContent(),
        );
    }

    public function getTid()
    {
        return $this->tid;
    }

    public function setTid($val)
    {
        $this->saveColumnStatus(0, $this->tid);
        $this->tid = $val;
    }

    public function getType()
    {
        return $this->type;
    }

    public function setType($val)
    {
        $this->saveColumnStatus(1, $this->type);
        $this->type = $val;
    }

    public function getTime()
    {
        return json_encode($this->time);
    }

    public function getRawTime()
    {
        return $this->time;
    }

    public function setTime($val)
    {
        $encodedLength = SzUtility::strLen(json_encode($val));
        if ($encodedLength > 25600) {
            SzLogger::get()->error('[TextScrollVo] The length of column time exceed the limit, length / limit: ' . $encodedLength . ' / 25600');
            throw new SzException(10522, array('TextScrollVo', '25600', $encodedLength));
        } else if ($encodedLength > 23040) {
            SzLogger::get()->warn('[TextScrollVo] The length of column time exceed the warning level, length / limit: ' . $encodedLength . ' / 25600');
        }
        $this->saveColumnStatus(2, $this->time);
        $this->time = $val;
    }

    public function getStart()
    {
        return $this->start;
    }

    public function setStart($val)
    {
        $this->saveColumnStatus(3, $this->start);
        $this->start = $val;
    }

    public function getEnd()
    {
        return $this->end;
    }

    public function setEnd($val)
    {
        $this->saveColumnStatus(4, $this->end);
        $this->end = $val;
    }

    public function getContent()
    {
        return $this->content;
    }

    public function setContent($val)
    {
        $this->saveColumnStatus(5, $this->content);
        $this->content = $val;
    }

}